<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>图书畅销榜</title>
    <%--引入vue的js--%>
    <script src="https://unpkg.com/vue@2/dist/vue.js"></script>
    <%--引入element的js--%>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="/js/axios.min.js"></script>
    <%--引入elementui的样式--%>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入Element UI样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

    <style>
        h1{
            color: #3366ff; /* 设置标题颜色为蓝色 */
            text-align: center; /* 设置标题文本居中对齐 */
            font-family: "Arial", sans-serif; /* 设置标题字体为Arial */
            font-size: 24px; /* 设置标题字体大小为24像素 */
            font-weight: bold; /* 设置标题字体为粗体 */
            margin-bottom: 0; /* 移除标题的底部外边距 */
        }
    </style>
</head>
<body>

<div id="app">
    <el-container>
        <el-header><h1>最新榜单</h1></el-header>
        <el-main>
            <el-table
                    :data="newDates"
                    style="width: 100%">
                <el-table-column
                        label="发布日期"
                        prop="ebookRedate"
                        width="380">
                    <template slot-scope="scope">
                        <i class="el-icon-time"></i>
                        <span style="margin-left: 10px">{{ scope.row.ebookRedate }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                        label="图书名称"
                        prop="bookName"
                        width="380">
                    <template slot-scope="scope">
                        <el-popover trigger="hover" placement="top">
                            <p>图书名称: {{ scope.row.ebookName }}</p>
                            <p>图书作者: {{ scope.row.ebookAuthor }}</p>
                            <div slot="reference" class="name-wrapper">
                                <el-tag size="medium">{{ scope.row.ebookName }}</el-tag>
                            </div>
                        </el-popover>
                    </template>
                </el-table-column>
                <el-table-column label="评论" width="380">
                    <template slot-scope="scope">
                        <el-button
                                size="mini"
                                type="danger"
                                @click="comtrue(scope.row)">精彩评论</el-button>
                        <el-drawer
                                title="精彩评论"
                                :visible.sync="exciting"
                                direction="rtl"
                                size="50%">
                            <el-table :data="comData">
                                <el-table-column
                                        prop="user.userHead"
                                        label="用户头像"
                                        width="180">
                                    <template slot-scope="scope">
                                        <img style="width: 80px; height: 80px;border-radius: 40px" :src="scope.row.user.userHead">
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        prop="user.userNick"
                                        label="用户名称"
                                        width="180">
                                </el-table-column>
                                <el-table-column
                                        prop="ebookcommentMessage"
                                        label="评论">
                                </el-table-column>
                            </el-table>
                        </el-drawer>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
    </el-container>
</div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            //右侧抽屉效果绑定
            exciting:false,
            //最新日期图书信息
            newDates: [],
            table: false,
            // dialog: false,
            // loading: false,
            //图书评论数据
            comData: [],
        },
        created(){
            this.newList();
        },
        methods:{
            //最新图书表格数据
            newList(){
                axios.get("/ebook/newDate").then(result=>{
                    this.newDates=result.data.data;
                })
            },
            //图书评论信息
            comtrue(row){
                this.exciting=true;
                axios.post("/ebook/rowCom/"+row.ebookId).then(result=>{
                    this.comData=result.data.data
                })
            },
        }
    });
</script>
</html>
